package main;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class TestRockPaperScissors {

	public RockPaperScissors rps;

	@BeforeClass
	void setUpClass() {
		rps = new RockPaperScissors();
	}

	@AfterClass
	void tearDownClass() {
		rps = null;
	}

	@DataProvider(name = "lost")
	public Object[][] createLostData1() {
		return new Object[][] { { "ROCK", "PAPER" }, { "PAPER", "SCISSORS" },
				{ "SCISSORS", "ROCK" } };
	}

	@DataProvider(name = "win")
	public Object[][] createWinData1() {
		return new Object[][] { { "ROCK", "SCISSORS" }, { "PAPER", "ROCK" },
				{ "SCISSORS", "PAPER" } };
	}

	@DataProvider(name = "tie")
	public Object[][] createTieData1() {
		return new Object[][] { { "ROCK", "ROCK" }, { "PAPER", "PAPER" },
				{ "SCISSORS", "SCISSORS" } };
	}

	@Test(dataProvider = "win")
	@Parameters({ "PAPER", "ROCK" })
	void testWinPlay(@Optional("PAPER") String p1, @Optional("ROCK") String p2) {
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)),
				Result.WIN);
	}

	@Test(dataProvider = "tie")
	@Parameters({ "PAPER", "PAPER" })
	void testTiePlay(@Optional("PAPER") String p1, @Optional("PAPER") String p2) {
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)),
				Result.TIE);
	}

	@Test(dataProvider = "lost")
	@Parameters({ "ROCK", "PAPER" })
	void testLostPlay(@Optional("ROCK") String p1, @Optional("PAPER") String p2) {
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)),
				Result.LOST);
	}


}
